home *** CD-ROM | disk | FTP | other *** search
/ Libris Britannia 4 / science library(b).zip / science library(b) / PROGRAMM / PASCAL / 0187.ZIP / MAKEFILE.PAS < prev    next >
Pascal/Delphi Source File  |  1985-01-20  |  1KB  |  51 lines

  1. program makedict;
  2.  
  3. (*
  4.  * this program makes the datafile that is used by the hanggman game.
  5.  *)
  6.  
  7. const
  8.    stringsize = 10;
  9.  
  10. type
  11.    word = string[stringsize];
  12.  
  13. var
  14.    dict : file of word;
  15.    nextword : word;
  16.    numwords : integer;
  17.  
  18. (*
  19.  * the dictionary for hangman is a file of strings. it cannot be a text
  20.  * file because seeking is not allowed on text, and hangman uses a random
  21.  * seek to get the word. the first string in the file contains the
  22.  * number of words in the dictionary.
  23.  *)
  24.  
  25. begin
  26.    numwords := 0;
  27.    nextword := '';
  28.    assign(dict, 'words.dat');
  29.    rewrite(dict);
  30.    str(0,nextword);
  31.    write(dict,nextword);
  32.    writeln('Type the words to be entered into the dictionary; no more than');
  33.    writeln(stringsize:1,' letters long. Type the end-of-file character to exit.');
  34.    nextword := '';
  35.    readln(nextword);
  36.    while not eof(con) and (length(nextword) > 0) do
  37.       begin
  38.       write(dict,nextword);
  39.       numwords := numwords + 1;
  40.       nextword := '';
  41.       readln(nextword);
  42.    end;
  43.    writeln('That''s all, folks!');
  44.    seek(dict,0);
  45.    nextword := '';
  46.    str(numwords,nextword);
  47.    write(dict,nextword);
  48.    close(dict);
  49. end.
  50.  
  51.